//复制指定次数字符串    ---repeat(i)
let a = "b"
console.log(a.repeat(3), "复制指定次数字符串")


//截取特定字符串中间的内容
let b = ";我’;是’;好’;人’"
let key1 = ";"
let key2 = "’"
let num1
let num2
let arr1 = []
let arr2 = []
for (let i = 0; i < b.length; i++) {
    if (b.indexOf(key1, num1) != -1) {
        arr1.push(b.indexOf(key1, num1))
        num1 = b.indexOf(key1, num1) + 1
    }
    if (b.indexOf(key2, num2) != -1) {
        arr2.push(b.indexOf(key2, num2))
        num2 = b.indexOf(key2, num2) + 1
    }
}
let res = ""
arr1.forEach((e, index) => {
    res += b.slice(e+1, arr2[index])
});
console.log(res, "截取特定字符串中间的内容");

//lastIndexOf/firstIndexOf 找到指定元素最后一次/第一次出现的位置
console.log("abcacb".lastIndexOf("a"), "abcacb".indexOf("b"));

//split 以指定字符将字符串变成数组  
console.log("abc".split(""));

//slice 分割字符串  包左不包右
console.log("abcc".slice(0,3))

//数组去重
// let agin = [1,1,2,3,3,4,5]
// let set = new Set()
// agin.forEach(element => {
//     set.add(element)
// });
// console.log([...set]);

//全量替换
let str = "111111111"
console.log(str.replaceAll("1","2"));
console.log(str.replace(/1/g,"2"));

//将数组内指定位置替换成第一个参数 包左不包右

console.log([0, 1, 2, 3].fill("R",1,2));

//排序

console.log([2,5,8,7,9,4].sort((a,b) => {
   return a-b
}));

//splice(第几位，删除几个，替换成什么)